home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / andere sprachen / perl5 / perl5.002 / makedepend.sh < prev    next >
Encoding:
Text File  |  1996-02-29  |  4.8 KB  |  170 lines

  1. case $CONFIG in
  2. '')
  3.     if test -f config.sh; then TOP=.;
  4.     elif test -f ../config.sh; then TOP=..;
  5.     elif test -f ../../config.sh; then TOP=../..;
  6.     elif test -f ../../../config.sh; then TOP=../../..;
  7.     elif test -f ../../../../config.sh; then TOP=../../../..;
  8.     else
  9.         echo "Can't find config.sh."; exit 1
  10.     fi
  11.     . $TOP/config.sh
  12.     ;;
  13. esac
  14. : This forces SH files to create target in same directory as SH file.
  15. : This is so that make depend always knows where to find SH derivatives.
  16. case "$0" in
  17. */*) cd `expr X$0 : 'X\(.*\)/'` ;;
  18. esac
  19. echo "Extracting makedepend (with variable substitutions)"
  20. rm -f makedepend
  21. $spitshell >makedepend <<!GROK!THIS!
  22. $startsh
  23. # makedepend.SH
  24. #
  25. ## To use an alternate make, set \$altmake in config.sh.
  26. MAKE=${altmake-make}
  27. !GROK!THIS!
  28. $spitshell >>makedepend <<'!NO!SUBS!'
  29.  
  30. export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh \$0; kill \$\$)
  31.  
  32. case $CONFIG in
  33. '')
  34.     if test -f config.sh; then TOP=.;
  35.     elif test -f ../config.sh; then TOP=..;
  36.     elif test -f ../../config.sh; then TOP=../..;
  37.     elif test -f ../../../config.sh; then TOP=../../..;
  38.     elif test -f ../../../../config.sh; then TOP=../../../..;
  39.     else
  40.         echo "Can't find config.sh."; exit 1
  41.     fi
  42.     . $TOP/config.sh
  43.     ;;
  44. esac
  45.  
  46. # We need .. when we are in the x2p directory if we are using the
  47. # cppstdin wrapper script.
  48. # Put .. and . first so that we pick up the present cppstdin, not
  49. # an older one lying about in /usr/local/bin.
  50. PATH=".:..:$PATH"
  51. export PATH
  52.  
  53. $cat /dev/null >.deptmp
  54. $rm -f *.c.c c/*.c.c
  55. if test -f Makefile; then
  56.     cp Makefile GNUmakefile
  57. fi
  58. mf=GNUmakefile
  59. if test -f $mf; then
  60.     defrule=`<$mf sed -n        \
  61.     -e '/^\.c\.o:.*;/{'        \
  62.     -e    's/\$\*\.c//'        \
  63.     -e    's/^[^;]*;[     ]*//p'    \
  64.     -e    q                \
  65.     -e '}'                \
  66.     -e '/^\.c\.o: *$/{'        \
  67.     -e    N                \
  68.     -e    's/\$\*\.c//'        \
  69.     -e    's/^.*\n[     ]*//p'        \
  70.     -e    q                \
  71.     -e '}'`
  72. fi
  73. case "$defrule" in
  74. '') defrule='$(CC) -c $(CFLAGS)' ;;
  75. esac
  76.  
  77. : Create files in UU directory to avoid problems with long filenames
  78. : on systems with 14 character filename limits so file.c.c and file.c
  79. : might be identical
  80. $test -d UU || mkdir UU
  81.  
  82. $MAKE clist || ($echo "Searching for .c files..."; \
  83.     $echo *.c | $tr ' ' '\012' | $egrep -v '\*' >.clist)
  84. for file in `$cat .clist`; do
  85. # for file in `cat /dev/null`; do
  86.     case "$file" in
  87.     *.c) filebase=`basename $file .c` ;;
  88.     *.y) filebase=`basename $file .y` ;;
  89.     esac
  90.     case "$file" in
  91.     */*) finc="-I`echo $file | sed 's#/[^/]*$##`" ;;
  92.     *)   finc= ;;
  93.     esac
  94.     $echo "Finding dependencies for $filebase.o."
  95.     ( $echo "#line 1 \"$file\""; \
  96.       $sed -n <$file \
  97.     -e "/^${filebase}_init(/q" \
  98.     -e '/^#line/d' \
  99.     -e '/^#/{' \
  100.     -e 's|/\*.*$||' \
  101.     -e 's|\\$||' \
  102.     -e p \
  103.     -e '}' ) >UU/$file.c
  104.     $cppstdin $finc -I/usr/local/include -I. $cppflags $cppminus <UU/$file.c |
  105.     $sed \
  106.     -e '/^#.*<stdin>/d' \
  107.     -e 's#\.[0-9][0-9]*\.c#'"$file.c#" \
  108.     -e 's/^[     ]*#[     ]*line/#/' \
  109.     -e '/^# *[0-9][0-9]* *[".\/]/!d' \
  110.     -e 's/^.*"\(.*\)".*$/'$filebase'.o: \1/' \
  111.     -e 's/^# *[0-9][0-9]* \(.*\)$/'$filebase'.o: \1/' \
  112.     -e 's|: \./|: |' \
  113.     -e 's|\.c\.c|.c|' | \
  114.     $uniq | $sort | $uniq >> .deptmp
  115. done
  116.  
  117. $sed <$mf >$mf.new -e '1,/^# AUTOMATICALLY/!d'
  118.  
  119. $MAKE shlist || ($echo "Searching for .SH files..."; \
  120.     $echo *.SH | $tr ' ' '\012' | $egrep -v '\*' >.shlist)
  121. if $test -s .deptmp; then
  122.     for file in `cat .shlist`; do
  123.     $echo `$expr X$file : 'X\(.*\).SH'`: $file $TOP/config.sh \; \
  124.         /bin/sh $file >> .deptmp
  125.     done
  126.     $echo "Updating $mf..."
  127.     $echo "# If this runs make out of memory, delete /usr/include lines." \
  128.     >> $mf.new
  129.     $sed 's|^\(.*\.o:\) *\(.*/.*\.c\) *$|\1 \2; '"$defrule \2|" .deptmp \
  130.        >>$mf.new
  131. else
  132.     $MAKE hlist || ($echo "Searching for .h files..."; \
  133.     $echo *.h | $tr ' ' '\012' | $egrep -v '\*' >.hlist)
  134.     $echo "You don't seem to have a proper C preprocessor.  Using grep instead."
  135.     $egrep '^#include ' `cat .clist` `cat .hlist`  >.deptmp
  136.     $echo "Updating $mf..."
  137.     <.clist $sed -n                            \
  138.     -e '/\//{'                            \
  139.     -e   's|^\(.*\)/\(.*\)\.c|\2.o: \1/\2.c; '"$defrule \1/\2.c|p"    \
  140.     -e   d                                \
  141.     -e '}'                                \
  142.     -e 's|^\(.*\)\.c|\1.o: \1.c|p' >> $mf.new
  143.     <.hlist $sed -n 's|\(.*/\)\(.*\)|s= \2= \1\2=|p' >.hsed
  144.     <.deptmp $sed -n 's|c:#include "\(.*\)".*$|o: \1|p' | \
  145.        $sed 's|^[^;]*/||' | \
  146.        $sed -f .hsed >> $mf.new
  147.     <.deptmp $sed -n 's|h:#include "\(.*\)".*$|h: \1|p' | \
  148.        $sed -f .hsed >> $mf.new
  149.     for file in `$cat .shlist`; do
  150.     $echo `$expr X$file : 'X\(.*\).SH'`: $file $TOP/config.sh \; \
  151.         /bin/sh $file >> $mf.new
  152.     done
  153. fi
  154. $rm -f $mf.old
  155. $cp $mf $mf.old
  156. $cp $mf.new $mf
  157. $rm $mf.new
  158. $echo "# WARNING: Put nothing here or make depend will gobble it up!" >> $mf
  159. $rm -rf .deptmp UU .shlist .clist .hlist .hsed
  160.  
  161. !NO!SUBS!
  162. $eunicefix makedepend
  163. chmod +x makedepend
  164. case `pwd` in
  165. *SH)
  166.     $rm -f ../makedepend
  167.     ln makedepend ../makedepend
  168.     ;;
  169. esac
  170.